<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace Application\Service;

/**
 */
class ErrorHandlingService
{

    /**
     */
    protected $logger;

    /**
     */
    function __construct($logger)
    {
        $this->logger = $logger;
    }

    /**
     *
     * @param \Exception $e            
     */
    function logException(\Exception $e)
    {
        $trace = $e->getTraceAsString();
        $i = 1;
        
        do {
            $messages[] = $i ++ . ": " . $e->getMessage();
        } while ($e = $e->getPrevious());
        
        $log = "Exception:\n" . implode("\n", $messages);
        $log .= "\nTrace:\n" . $trace;
        
        $this->logger->err($log);
    }
}

?>